package com.salesmonitoring.connector;

import java.sql.Connection;
import java.sql.DriverManager;

public class Connector {

	private final String USERNAME = "root";
	private final String PASSWORD = "";
	private final String HOST = "jdbc:mysql://localhost:3306/sales_monitoring";
	private final String DRIVER = "com.mysql.jdbc.Driver";
	
	private Connection con;
	
	private static Connector connector;
	
	public static synchronized Connector getInstance() {
	
		if(connector == null) {
			connector = new Connector();
		}
		
		return connector;
	}
	
	public Connection getConnection() {
		
		try {
			Class.forName(DRIVER).newInstance();
			con = DriverManager.getConnection(HOST, USERNAME, PASSWORD);
		} catch(Exception e) {
			e.printStackTrace();
		}
		
		return con;
		
	}
	
}
